package com.changcheng.project.obupublishlog.controller;

import java.util.List;


import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.obupublishlog.domain.AObuPublishLog;
import com.changcheng.project.obupublishlog.service.IAObuPublishLogService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * obu发布记录Controller
 * 
 * @author dazhi
 * @date 2020-10-31
 */
@Controller
@RequestMapping("/obupublishlog/obupublishlog")
public class AObuPublishLogController extends BaseController
{
    private String prefix = "obupublishlog/obupublishlog";

    @Autowired
    private IAObuPublishLogService aObuPublishLogService;

    @RequiresPermissions("obupublishlog:obupublishlog:view")
    @GetMapping()
    public String obupublishlog()
    {
        return prefix + "/obupublishlog";
    }

    /**
     * 查询obu发布记录列表
     */
    @RequiresPermissions("obupublishlog:obupublishlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AObuPublishLog aObuPublishLog)
    {
        startPage();
        List<AObuPublishLog> list = aObuPublishLogService.selectAObuPublishLogList(aObuPublishLog);
        return getDataTable(list);
    }

    /**
     * 导出obu发布记录列表
     */
    @RequiresPermissions("obupublishlog:obupublishlog:export")
    @Log(title = "obu发布记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AObuPublishLog aObuPublishLog)
    {
        List<AObuPublishLog> list = aObuPublishLogService.selectAObuPublishLogList(aObuPublishLog);
        ExcelUtil<AObuPublishLog> util = new ExcelUtil<AObuPublishLog>(AObuPublishLog.class);
        return util.exportExcel(list, "obupublishlog");
    }

    /**
     * 新增obu发布记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存obu发布记录
     */
    @RequiresPermissions("obupublishlog:obupublishlog:add")
    @Log(title = "obu发布记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AObuPublishLog aObuPublishLog)
    {
        return toAjax(aObuPublishLogService.insertAObuPublishLog(aObuPublishLog));
    }

    /**
     * 修改obu发布记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AObuPublishLog aObuPublishLog = aObuPublishLogService.selectAObuPublishLogById(id);
        mmap.put("aObuPublishLog", aObuPublishLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存obu发布记录
     */
    @RequiresPermissions("obupublishlog:obupublishlog:edit")
    @Log(title = "obu发布记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AObuPublishLog aObuPublishLog)
    {
        return toAjax(aObuPublishLogService.updateAObuPublishLog(aObuPublishLog));
    }

    /**
     * 删除obu发布记录
     */
    @RequiresPermissions("obupublishlog:obupublishlog:remove")
    @Log(title = "obu发布记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aObuPublishLogService.deleteAObuPublishLogByIds(ids));
    }
}
